import { createAction } from "redux-actions";
import { DoctorData } from "../../type/DoctorData";
import { HospitalInfo } from "../../type/HospitalData";
import {
  LOGIN,
  LOGOUT,
  SET_DOCTOR_LIST,
  SET_HOSPITAL_LIST
} from "../AcrionTypes";
import { getUserData } from "../../utils/auth";

/**
 * 设置医院列表数据
 * @description createAction配合handleActions使用，
 * 此为redux-action组件提供的功能，使创建reducer和Action更加便捷
 * 还可以使用 createAction（）方法
 */
export const setHispitalList = createAction(
  SET_HOSPITAL_LIST,
  (hospitalList: HospitalInfo[]) => {
    return hospitalList;
  }
);
/**
 * 设置医生列表数据
 */
export const setDoctorlist = createAction(
  SET_DOCTOR_LIST,
  (doctorList: DoctorData[]) => {
    return doctorList;
  }
);
/**
 * 登录
 */
export const login = createAction(LOGIN, () => {
  return getUserData();
});
/**
 * 登出
 */
export const logOut = createAction(LOGOUT);
